package Functions;
#use lib "/data/tools/repository/perl-5.8.8/lib/site_perl/5.8.8/";
use strict;
use warnings;

use POSIX qw(strftime);

my $G_LOG;

sub get_hash_size
{
    my $href_hash=shift @_;
    my $counter=0;
    
    foreach my $elements (keys %{$href_hash} )
    {
	$counter++;
    }
    return $counter;

}

sub print_hash_content
{
    my $href_hash=shift @_;

    print "Printing Hash Content:\n";
    print "######################################################\n";
    foreach my $thekey (keys %$href_hash)
    {
	print $thekey." => ".$href_hash->{$thekey}."\n";
    }
    print "######################################################\n";
}

sub get_time
{
    my $separator=shift @_;
    my $now_time="";
    
    if (! defined $separator)
    {
	$separator=":";
    }
    
    $now_time = strftime("%H".$separator."%M".$separator."%S",localtime());
    
    return $now_time;
}

sub get_date
{
    my $separator=shift @_;
    my $now_date="";
    
    if (! defined $separator)
    {
	$separator="/";
    }
    
    $now_date = strftime("%Y".$separator."%m".$separator."%d",localtime());
    
    return $now_date;
}

sub mylog
{
    if ($G_LOG)
    {
	print $G_LOG get_date()." ".get_time()." ".join("",@_);
    }
}

sub error
{
    print STDERR get_date()." ".get_time()." [ERROR] ",@_;
    return;
    mylog "[ERROR] ", @_;
}

sub warning
{
    print STDERR get_date()." ".get_time()." [WARNING] ",@_;
    return;
    mylog("[WARNING],",@_);
}

sub info
{
    print STDOUT get_date()." ".get_time()." [INFO] ",@_;
    return;
    mylog("[INFO] ",@_);
}

1;

